
package com.dynamixsoftware.printershare;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import com.dynamixsoftware.printershare.bt.BTAdapter;
import com.dynamixsoftware.printershare.bt.BTDevice;
import com.dynamixsoftware.printershare.data.Printer;
import com.dynamixsoftware.printershare.data.User;
import java.util.Vector;

public class ScanThreadBluetooth
		extends Thread
{
	private BroadcastReceiver br;
	private BTAdapter bta;
	private Context context;
	private boolean destroyed = false;
	private Vector<Printer> printers;
	private String rq_pid;
	private Handler status;
	private int timeout;

	public ScanThreadBluetooth(Context paramContext, int paramInt, String paramString, Handler paramHandler)
	{
		this.context = paramContext;
		this.timeout = paramInt;
		this.rq_pid = paramString;
		this.status = paramHandler;
		this.printers = new Vector();
	}

	private boolean parseDev(BTDevice paramBTDevice, boolean paramBoolean)
	{
		Integer localInteger = paramBTDevice.getDeviceClass();
		if (localInteger == null) {
			return false;
		}
		String str2 = paramBTDevice.getName();
		if ((str2 == null) || ("".equals(str2))) {
			return false;
		}
		// }
		// } while (!paramBoolean);
		String str1 = paramBTDevice.getAddress();
		String str3 = str1 + "._pdl-datastream._bluetooth.local.";
		if ((this.rq_pid != null) && (!str3.equals(this.rq_pid))) {
			return true;
		}
		Printer localPrinter = new Printer();
		localPrinter.id = str3;
		localPrinter.online = true;
		localPrinter.owner = new User();
		localPrinter.owner.name = str1;
		localPrinter.direct_address = ("bluetooth://" + paramBTDevice.getAddress());
		int n;
		StringBuilder localStringBuilder;
		String str5;
		if (str2 != null)
		{
			str2 = str2.trim();
			if ((str2.lastIndexOf("-") == -2 + str2.length()) && (str2.charAt(-1 + str2.length()) >= '0')
					&& (str2.charAt(-1 + str2.length()) <= '9')) {
				str2 = str2.substring(0, -2 + str2.length()).trim();
			}
			int i = str2.indexOf("(");
			if (i >= 0) {
				str2 = str2.substring(0, i).trim();
			}
			int j = str2.indexOf(" S/N");
			if (j >= 0) {
				str2 = str2.substring(0, j).trim();
			}
			int k = str2.indexOf(" SN:");
			if (k >= 0) {
				str2 = str2.substring(0, k).trim();
			}
			int m = str2.indexOf(" series-");
			if (m >= 0) {
				str2 = str2.substring(0, m + 1).concat("series");
			}
			if ((str2.startsWith("Photosmart")) || (str2.startsWith("Officejet")) || (str2.startsWith("Deskjet"))
					|| (str2.startsWith("dj450"))) {
				str2 = "HP " + str2;
			}
			if (str2.startsWith("Stylus Photo")) {
				str2 = "Epson " + str2;
			}
			if (str2.startsWith("OJL411")) {
				str2 = "HP Officejet 100 Mobile l411";
			}
			if ((str2.startsWith("OJL511")) || ("OfficeJet150".equals(str2))) {
				str2 = "HP OfficeJet 150 Mobile l511";
			}
			if ((str2.startsWith("PJ-")) || (str2.startsWith("MW-")) || (str2.startsWith("RJ-"))) {
				str2 = "Brother " + str2.substring(0, -4 + str2.length());
			}
			if (str2.startsWith("MFC-")) {
				str2 = "Brother " + str2;
			}
			if (str2.startsWith("ASL Ap"))
			{
				n = str2.indexOf("-");
				localStringBuilder = new StringBuilder().append("Able ");
				if (n >= 0) {
					break label764;
				}
				str5 = str2.substring(4);
			}
		}
		for (;;)
		{
			str2 = str5.trim();
			String str4;
			if (str2 != null)
			{
				str4 = str2;
				localPrinter.model = str4;
				if ((str2 == null) || (str1.equals(str2))) {
					str2 = "Bluetooth Printer";
				}
				localPrinter.title = str2;
			}
			synchronized (this.printers)
			{
				this.printers.add(localPrinter);
				Message localMessage = new Message();
				localMessage.what = 2;
				this.status.sendMessage(localMessage);
				return true;
				label764: str5 = str2.substring(4, n);
				continue;
				str4 = "";
			}
		}
	}

	public void destroy()
	{
		this.destroyed = true;
		interrupt();
	}

	public Vector<Printer> getPrinters()
	{
		return this.printers;
	}

	/* Error */
	public void run()
	{
		// Byte code:
		// 0: new 205 android/os/Message
		// 3: dup
		// 4: invokespecial 206 android/os/Message:<init> ()V
		// 7: astore_1
		// 8: aload_1
		// 9: iconst_1
		// 10: putfield 209 android/os/Message:what I
		// 13: aload_0
		// 14: getfield 36
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:status
		// Landroid/os/Handler;
		// 17: aload_1
		// 18: invokevirtual 215 android/os/Handler:sendMessage
		// (Landroid/os/Message;)Z
		// 21: pop
		// 22: aload_0
		// 23: getfield 28
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:destroyed Z
		// 26: istore_3
		// 27: aconst_null
		// 28: astore 4
		// 30: iload_3
		// 31: ifne +464 -> 495
		// 34: new 38 java/util/Vector
		// 37: dup
		// 38: invokespecial 39 java/util/Vector:<init> ()V
		// 41: astore 5
		// 43: aload_0
		// 44: aload_0
		// 45: getfield 30
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:context
		// Landroid/content/Context;
		// 48: invokestatic 230
		// com/dynamixsoftware/printershare/bt/BTAdapter:getDefault
		// (Landroid/content/Context;)Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 51: putfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 54: aload_0
		// 55: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 58: astore 29
		// 60: aconst_null
		// 61: astore 4
		// 63: aload 29
		// 65: ifnull +77 -> 142
		// 68: aload_0
		// 69: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 72: invokevirtual 234
		// com/dynamixsoftware/printershare/bt/BTAdapter:isEnabled ()Z
		// 75: istore 30
		// 77: aconst_null
		// 78: astore 4
		// 80: iload 30
		// 82: ifeq +60 -> 142
		// 85: aload_0
		// 86: new 236 com/dynamixsoftware/printershare/ScanThreadBluetooth$1
		// 89: dup
		// 90: aload_0
		// 91: aload 5
		// 93: invokespecial 239
		// com/dynamixsoftware/printershare/ScanThreadBluetooth$1:<init>
		// (Lcom/dynamixsoftware/printershare/ScanThreadBluetooth;Ljava/util/Vector;)V
		// 96: putfield 241
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:br
		// Landroid/content/BroadcastReceiver;
		// 99: aload_0
		// 100: getfield 30
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:context
		// Landroid/content/Context;
		// 103: aload_0
		// 104: getfield 241
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:br
		// Landroid/content/BroadcastReceiver;
		// 107: aload_0
		// 108: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 111: invokevirtual 245
		// com/dynamixsoftware/printershare/bt/BTAdapter:getDiscoveryIntentFilter
		// ()Landroid/content/IntentFilter;
		// 114: invokevirtual 251 android/content/Context:registerReceiver
		// (Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;
		// 117: pop
		// 118: aload_0
		// 119: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 122: invokevirtual 254
		// com/dynamixsoftware/printershare/bt/BTAdapter:isDiscovering ()Z
		// 125: ifeq +10 -> 135
		// 128: aload_0
		// 129: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 132: invokevirtual 257
		// com/dynamixsoftware/printershare/bt/BTAdapter:cancelDiscovery ()V
		// 135: aload_0
		// 136: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 139: invokevirtual 260
		// com/dynamixsoftware/printershare/bt/BTAdapter:startDiscovery ()V
		// 142: aload 4
		// 144: ifnonnull +351 -> 495
		// 147: aload_0
		// 148: getfield 241
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:br
		// Landroid/content/BroadcastReceiver;
		// 151: ifnull +344 -> 495
		// 154: invokestatic 266 java/lang/System:currentTimeMillis ()J
		// 157: lstore 12
		// 159: new 38 java/util/Vector
		// 162: dup
		// 163: invokespecial 39 java/util/Vector:<init> ()V
		// 166: astore 14
		// 168: new 268 java/util/HashSet
		// 171: dup
		// 172: invokespecial 269 java/util/HashSet:<init> ()V
		// 175: astore 15
		// 177: aload 5
		// 179: monitorenter
		// 180: aload 5
		// 182: invokevirtual 272 java/util/Vector:size ()I
		// 185: istore 23
		// 187: aconst_null
		// 188: astore 24
		// 190: iload 23
		// 192: ifle +14 -> 206
		// 195: aload 5
		// 197: iconst_0
		// 198: invokevirtual 276 java/util/Vector:remove (I)Ljava/lang/Object;
		// 201: checkcast 49 com/dynamixsoftware/printershare/bt/BTDevice
		// 204: astore 24
		// 206: aload 5
		// 208: monitorexit
		// 209: aload 24
		// 211: ifnull +237 -> 448
		// 214: aload 15
		// 216: aload 24
		// 218: invokevirtual 74
		// com/dynamixsoftware/printershare/bt/BTDevice:getAddress
		// ()Ljava/lang/String;
		// 221: invokevirtual 279 java/util/HashSet:contains
		// (Ljava/lang/Object;)Z
		// 224: istore 26
		// 226: iload 26
		// 228: ifeq +199 -> 427
		// 231: aload_0
		// 232: getfield 28
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:destroyed Z
		// 235: ifne +28 -> 263
		// 238: aload_0
		// 239: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 242: invokevirtual 254
		// com/dynamixsoftware/printershare/bt/BTAdapter:isDiscovering ()Z
		// 245: ifeq +18 -> 263
		// 248: invokestatic 266 java/lang/System:currentTimeMillis ()J
		// 251: lload 12
		// 253: lsub
		// 254: aload_0
		// 255: getfield 32
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:timeout I
		// 258: i2l
		// 259: lcmp
		// 260: iflt -83 -> 177
		// 263: aload_0
		// 264: getfield 30
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:context
		// Landroid/content/Context;
		// 267: aload_0
		// 268: getfield 241
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:br
		// Landroid/content/BroadcastReceiver;
		// 271: invokevirtual 283 android/content/Context:unregisterReceiver
		// (Landroid/content/BroadcastReceiver;)V
		// 274: aload_0
		// 275: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 278: invokevirtual 254
		// com/dynamixsoftware/printershare/bt/BTAdapter:isDiscovering ()Z
		// 281: ifeq +10 -> 291
		// 284: aload_0
		// 285: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 288: invokevirtual 257
		// com/dynamixsoftware/printershare/bt/BTAdapter:cancelDiscovery ()V
		// 291: iconst_0
		// 292: istore 17
		// 294: iload 17
		// 296: aload 14
		// 298: invokevirtual 272 java/util/Vector:size ()I
		// 301: if_icmpge +194 -> 495
		// 304: aload_0
		// 305: getfield 45
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:bta
		// Lcom/dynamixsoftware/printershare/bt/BTAdapter;
		// 308: aload 14
		// 310: iconst_0
		// 311: invokevirtual 276 java/util/Vector:remove (I)Ljava/lang/Object;
		// 314: checkcast 49 com/dynamixsoftware/printershare/bt/BTDevice
		// 317: invokevirtual 74
		// com/dynamixsoftware/printershare/bt/BTDevice:getAddress
		// ()Ljava/lang/String;
		// 320: invokevirtual 287
		// com/dynamixsoftware/printershare/bt/BTAdapter:getRemoteDevice
		// (Ljava/lang/String;)Lcom/dynamixsoftware/printershare/bt/BTDevice;
		// 323: astore 19
		// 325: aload 15
		// 327: aload 19
		// 329: invokevirtual 74
		// com/dynamixsoftware/printershare/bt/BTDevice:getAddress
		// ()Ljava/lang/String;
		// 332: invokevirtual 279 java/util/HashSet:contains
		// (Ljava/lang/Object;)Z
		// 335: ifne +22 -> 357
		// 338: aload_0
		// 339: aload 19
		// 341: iconst_1
		// 342: invokespecial 289
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:parseDev
		// (Lcom/dynamixsoftware/printershare/bt/BTDevice;Z)Z
		// 345: pop
		// 346: aload 15
		// 348: aload 19
		// 350: invokevirtual 74
		// com/dynamixsoftware/printershare/bt/BTDevice:getAddress
		// ()Ljava/lang/String;
		// 353: invokevirtual 290 java/util/HashSet:add (Ljava/lang/Object;)Z
		// 356: pop
		// 357: iinc 17 1
		// 360: goto -66 -> 294
		// 363: astore 6
		// 365: new 76 java/lang/StringBuilder
		// 368: dup
		// 369: invokespecial 77 java/lang/StringBuilder:<init> ()V
		// 372: ldc_w 292
		// 375: invokevirtual 81 java/lang/StringBuilder:append
		// (Ljava/lang/String;)Ljava/lang/StringBuilder;
		// 378: aload 6
		// 380: invokevirtual 295 java/lang/Exception:getMessage
		// ()Ljava/lang/String;
		// 383: invokevirtual 81 java/lang/StringBuilder:append
		// (Ljava/lang/String;)Ljava/lang/StringBuilder;
		// 386: invokevirtual 86 java/lang/StringBuilder:toString
		// ()Ljava/lang/String;
		// 389: astore 4
		// 391: aload 6
		// 393: invokevirtual 298 java/lang/Exception:printStackTrace ()V
		// 396: aload 6
		// 398: invokestatic 304
		// com/dynamixsoftware/printershare/App:reportThrowable
		// (Ljava/lang/Throwable;)V
		// 401: goto -259 -> 142
		// 404: astore 22
		// 406: aload 5
		// 408: monitorexit
		// 409: aload 22
		// 411: athrow
		// 412: astore 16
		// 414: aload 16
		// 416: invokevirtual 298 java/lang/Exception:printStackTrace ()V
		// 419: aload 16
		// 421: invokestatic 304
		// com/dynamixsoftware/printershare/App:reportThrowable
		// (Ljava/lang/Throwable;)V
		// 424: goto -133 -> 291
		// 427: aload_0
		// 428: aload 24
		// 430: iconst_0
		// 431: invokespecial 289
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:parseDev
		// (Lcom/dynamixsoftware/printershare/bt/BTDevice;Z)Z
		// 434: ifeq +20 -> 454
		// 437: aload 15
		// 439: aload 24
		// 441: invokevirtual 74
		// com/dynamixsoftware/printershare/bt/BTDevice:getAddress
		// ()Ljava/lang/String;
		// 444: invokevirtual 290 java/util/HashSet:add (Ljava/lang/Object;)Z
		// 447: pop
		// 448: invokestatic 307 java/lang/Thread:yield ()V
		// 451: goto -220 -> 231
		// 454: aload 14
		// 456: aload 24
		// 458: invokevirtual 203 java/util/Vector:add (Ljava/lang/Object;)Z
		// 461: pop
		// 462: goto -14 -> 448
		// 465: astore 25
		// 467: aload 25
		// 469: invokevirtual 298 java/lang/Exception:printStackTrace ()V
		// 472: aload 25
		// 474: invokestatic 304
		// com/dynamixsoftware/printershare/App:reportThrowable
		// (Ljava/lang/Throwable;)V
		// 477: goto -29 -> 448
		// 480: astore 18
		// 482: aload 18
		// 484: invokevirtual 298 java/lang/Exception:printStackTrace ()V
		// 487: aload 18
		// 489: invokestatic 304
		// com/dynamixsoftware/printershare/App:reportThrowable
		// (Ljava/lang/Throwable;)V
		// 492: goto -135 -> 357
		// 495: aload 4
		// 497: ifnull +61 -> 558
		// 500: new 205 android/os/Message
		// 503: dup
		// 504: invokespecial 206 android/os/Message:<init> ()V
		// 507: astore 7
		// 509: aload 7
		// 511: iconst_3
		// 512: putfield 209 android/os/Message:what I
		// 515: aload 7
		// 517: iconst_3
		// 518: putfield 310 android/os/Message:arg1 I
		// 521: new 312 android/os/Bundle
		// 524: dup
		// 525: invokespecial 313 android/os/Bundle:<init> ()V
		// 528: astore 8
		// 530: aload 8
		// 532: ldc_w 315
		// 535: aload 4
		// 537: invokevirtual 319 android/os/Bundle:putString
		// (Ljava/lang/String;Ljava/lang/String;)V
		// 540: aload 7
		// 542: aload 8
		// 544: invokevirtual 323 android/os/Message:setData
		// (Landroid/os/Bundle;)V
		// 547: aload_0
		// 548: getfield 36
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:status
		// Landroid/os/Handler;
		// 551: aload 7
		// 553: invokevirtual 215 android/os/Handler:sendMessage
		// (Landroid/os/Message;)Z
		// 556: pop
		// 557: return
		// 558: new 205 android/os/Message
		// 561: dup
		// 562: invokespecial 206 android/os/Message:<init> ()V
		// 565: astore 10
		// 567: aload 10
		// 569: iconst_4
		// 570: putfield 209 android/os/Message:what I
		// 573: aload 10
		// 575: iconst_3
		// 576: putfield 310 android/os/Message:arg1 I
		// 579: aload_0
		// 580: getfield 36
		// com/dynamixsoftware/printershare/ScanThreadBluetooth:status
		// Landroid/os/Handler;
		// 583: aload 10
		// 585: invokevirtual 215 android/os/Handler:sendMessage
		// (Landroid/os/Message;)Z
		// 588: pop
		// 589: return
		// Local variable table:
		// start length slot name signature
		// 0 590 0 this ScanThreadBluetooth
		// 7 11 1 localMessage1 Message
		// 26 5 3 bool1 boolean
		// 28 508 4 str String
		// 41 366 5 localVector1 Vector
		// 363 34 6 localException1 Exception
		// 507 45 7 localMessage2 Message
		// 528 15 8 localBundle android.os.Bundle
		// 565 19 10 localMessage3 Message
		// 157 95 12 l long
		// 166 289 14 localVector2 Vector
		// 175 263 15 localHashSet java.util.HashSet
		// 412 8 16 localException2 Exception
		// 292 66 17 i int
		// 480 8 18 localException3 Exception
		// 323 26 19 localBTDevice1 BTDevice
		// 404 6 22 localObject Object
		// 185 6 23 j int
		// 188 269 24 localBTDevice2 BTDevice
		// 465 8 25 localException4 Exception
		// 224 3 26 bool2 boolean
		// 58 6 29 localBTAdapter BTAdapter
		// 75 6 30 bool3 boolean
		// Exception table:
		// from to target type
		// 43 60 363 java/lang/Exception
		// 68 77 363 java/lang/Exception
		// 85 135 363 java/lang/Exception
		// 135 142 363 java/lang/Exception
		// 180 187 404 finally
		// 195 206 404 finally
		// 206 209 404 finally
		// 406 409 404 finally
		// 177 180 412 java/lang/Exception
		// 231 263 412 java/lang/Exception
		// 263 291 412 java/lang/Exception
		// 409 412 412 java/lang/Exception
		// 448 451 412 java/lang/Exception
		// 467 477 412 java/lang/Exception
		// 214 226 465 java/lang/Exception
		// 427 448 465 java/lang/Exception
		// 454 462 465 java/lang/Exception
		// 304 357 480 java/lang/Exception
	}
}

/*
 * Location:
 * C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar
 * .jar Qualified Name: com.dynamixsoftware.printershare.ScanThreadBluetooth
 * JD-Core Version: 0.7.0.1
 */
